<template>
  <div class="education">
    <el-dialog
      :visible.sync="showDialog"
      width="100%"
      top="0"
      :close-on-click-modal="false"
      :lock-scroll="true"
      @close="close"
    >
      <div slot="title">
        <h4>{{form.id ? '编辑教育经历' : '添加教育经历'}}</h4>
        <small class="text-muted">请填写最高学历</small>
      </div>
      <el-form ref="form" :model="form" :rules="rules" :inline="true">
        <el-form-item label="教育开始时间" prop="start_time">
          <el-date-picker
            v-model="form.start_time"
            value-format="yyyy-MM"
            format="yyyy-MM"
            type="month"
            placeholder="请选择"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="教育结束时间" prop="end_time">
          <el-date-picker
            v-model="form.end_time"
            value-format="yyyy-MM"
            format="yyyy-MM"
            type="month"
            placeholder="请选择"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="毕业院校" prop="graduate_institutions">
          <el-input placeholder="请输入" v-model="form.graduate_institutions"></el-input>
        </el-form-item>
        <el-form-item label="毕业专业" prop="graduation_major">
          <el-input placeholder="请输入" v-model="form.graduation_major"></el-input>
        </el-form-item>
        <el-form-item label="学历" prop="education">
          <el-select v-model="form.education">
            <el-option
              v-for="education in educationList"
              :key="education"
              :label="education"
              :value="education"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="毕业证书编号" prop="graduation_certificate_number">
          <el-input placeholder="请输入" v-model="form.graduation_certificate_number"></el-input>
        </el-form-item>
        <el-form-item label="学位证书编号" prop="degree_certification_number">
          <el-input placeholder="请输入" v-model="form.degree_certification_number"></el-input>
        </el-form-item>
        <el-form-item label="教育备注" prop="remark">
          <el-input type="textarea" placeholder="请输入" v-model="form.remark"></el-input>
        </el-form-item>

        <el-button style="width: 100%" type="success" @click="finished">保存</el-button>
        <el-button v-if="row.id" style="width: 100%" type="default" @click="del">删除</el-button>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import common from '../mixins/common'

export default {
  name: 'Education',
  props: ['isVisible', 'row'],
  mixins: [common],
  data () {
    return {
      uuid: '',
      showDialog: false,
      form: {},
      rules: {
        education: [{ required: true, message: '学历必选', trigger: 'blur' }]
      },
      educationList: [],
      editUrl: '/home/user/saveEducation',
      delUrl: '/home/user/delEducation'
    }
  }
}
</script>
